//
//  AppBaseController.m
//  i5db
//
//  Created by iMuse on 15-5-12.
//  Copyright (c) 2015年 mySelf. All rights reserved.
//

#import "AppBaseController.h"
#import "AppCenter.h"
#import "SearchController.h"

@interface AppBaseController ()

@end

@implementation AppBaseController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
      
    }
    return self;
}
-(void) initSearchBar
{
    UIButton *search = [UIButton buttonWithType:UIButtonTypeCustom];
    [search setBackgroundImage:[UIImage imageNamed:@"qq_active_search_finder.png"]
                      forState:UIControlStateNormal];
    [search addTarget:self action:@selector(searchButton:)
     forControlEvents:UIControlEventTouchUpInside];
    search.frame = CGRectMake(0, 0, 20,20);
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:search];
    self.navigationItem.rightBarButtonItem = menuButton;
 
}
-(void)searchButton:(UIButton*) button
{
    SearchController * controller = [[SearchController alloc] init];
    [self presentViewController:controller animated:YES completion:nil];
    //[self.navigationController pushViewController:controller animated:YES];
}

- (void) initNavigationBar
{
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"btnBack.png"]
                      forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back:)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 44,44);
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = menuButton;
    /*
    //自定义返回按钮
    UIImage *backButtonImage = [[UIImage imageNamed:@"btnBack.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 44, 0, 0)];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    
    

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
     */
    /*[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bgNavigationBar.png"]
                                                  forBarMetrics:UIBarMetricsDefault];*/
    
    [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                             [AppCenter font:@"default,15"], NSFontAttributeName,nil]
                                   forState:UIControlStateNormal];
    
    [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                             [AppCenter color:@"141,149,159,1"], NSForegroundColorAttributeName,nil]
                                   forState:UIControlStateNormal];
    
    [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                             [AppCenter color:@"255,255,255,1"], NSForegroundColorAttributeName,nil]
                                   forState:UIControlStateSelected];
}

-(void)back:(UIButton*) button
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [AppCenter color:@"235,235,241,1"];
    [[IQKeyboardManager sharedManager]setEnable:YES];
  
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
  
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
